import tkinter as tk
import time
from tkinter import messagebox

root_window = tk.Tk()

root_window.title("My First GUI")
root_window.geometry("600x400")
print("电脑的分辨率为：%sx%s"%(root_window.winfo_screenwidth(),root_window.winfo_screenheight()))
root_window.update()
print("窗口的分辨率为：%sx%s"%(root_window.winfo_width(),root_window.winfo_height()))
root_window["background"]="#C9C7C2"
root_window.attributes("-topmost",True)
root_window.attributes("-alpha",1)
root_window.maxsize(600,600)
root_window.minsize(50,50)
root_window.iconbitmap("3f6474a390f53eaeec3b810f15737b3f.ico")
text=tk.Label(root_window,text="Hello World",bg="green",fg="#000000",font="Arial 20 bold")
text.pack()
button=tk.Button(root_window,text="关闭",command=root_window.quit)
button.pack(side=tk.BOTTOM)
def change_text():
    text.config(text="Goodbye World")
    print("修改成功")
button=tk.Button(root_window,text="修改",command=change_text)
button.pack(side=tk.BOTTOM)
def gettime():
    #获取当前时间
    dstr.set(time.strftime("%H:%M:%S"))
    root_window.after(1000,gettime)
dstr=tk.StringVar()
lb=tk.Label(root_window,textvariable=dstr,fg="black",font=("Arial",85))
lb.pack()
gettime()
label=tk.Label(root_window,text="欢迎回来",font=('宋体',20,'bold italic'),bg='blue',
               width=30,height=5,
               padx=10,pady=15,borderwidth=10,relief="sunken")
label.pack()
def click_button():
    messagebox.showinfo(title="提示！",message="猪妞欢迎你")
    print("点击了按钮")
button=tk.Button(root_window,text="点击前往",command=click_button,bg="#7CCD7C",width=20,height=5).pack ()
w=tk.Spinbox(root_window,from_=0,to=20,increment=2,width=15,bg='#9BCD9C')
w.pack()
root_window.mainloop()